﻿using TMPro;
using UnityEngine;

namespace Yoozoo.Gameplay.RTS
{
    public class MonsterHudLod1 : MonoBehaviour
    {
        private bool isVisible = false;
        public SpriteRenderer Icon;
        public SpriteRenderer LevelBg;
        public TMP_Text LevelText;
        private static Vector3 visibleScale = new Vector3(0.01f,0.01f,0.01f);
        private bool iconVisible;
        void Awake()
        {
            isVisible = LevelBg.gameObject.activeInHierarchy;
            if (Icon!=null)
            {
                iconVisible = Icon.gameObject.activeInHierarchy;
            }
        } 
        public void SetLevelBgIcon(string name)
        {
            ArmyManager.Instance.ResourceManager.SetMapElementAtlasIcon(name,LevelBg);
        }
    
        public void SetIcon(string name)
        {
            ArmyManager.Instance.ResourceManager.SetHeroRtsAtlasIcon(name,Icon);
        }
        public void SetMapElementIcon(string name)
        {
            ArmyManager.Instance.ResourceManager.SetMapElementAtlasIcon(name,Icon);
        }

        public void SetMapIcon(string name)
        {
            ArmyManager.Instance.ResourceManager.SetMapElementAtlasIcon(name, Icon);
        }
        
        public void SetLevelVisible(bool visible)
        {
            if (isVisible != visible)
            {
                LevelBg.enabled = visible;
                if (LevelText!=null)
                {
                    if (visible)
                    {
                        LevelText.transform.localScale = visibleScale;
                    }
                    else
                    {
                        LevelText.transform.localScale = Vector3.zero;
                    }
                }
                isVisible = visible;
            }
        }

        public void SetIconVisible(bool visible)
        {
            if (Icon!=null)
            {
                if (iconVisible!= visible)
                {
                    Icon.enabled = visible;
                    iconVisible = visible;
                }
            }
        }

    }


}
